    //存储的数据
    let fs=require('fs');
    let data = fs.readFileSync(__dirname+"/作业要求/persons.json","utf8");
    data = JSON.parse(data);
    let user = { username:"admin1",password:"12345" }

    // 存储的数据
    // let persons =data;
    // console.log(typeof data,data);
    // console.log(JSON.stringify(user));

    //验证是否注册
    let users = data.findIndex((item)=>{
       return item.username == user.username;
    })

    if(users == -1) 
    {
      console.log("用户名可以注册");
      data.push(user);
      let json = JSON.stringify(data);
      fs.writeFileSync(__dirname+"/作业要求/persons.json",json,{flag:"w"});
      console.log(data);
    }else
    {
      console.log("该用户已注册，请登录")  
    }


    // }